package cn.ywsj.ywsjmidtier.controller;

import cn.ywsj.ywsjmidtier.entity.VO.BrandVo;
import cn.ywsj.ywsjmidtier.service.WechatBrandFeign;
import cn.ywsj.ywsjmidtier.utils.JsonObjectUtil;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import static jdk.nashorn.internal.runtime.ECMAErrors.getMessage;

@Api(tags = "品牌")
@RestController
@RequestMapping("/wechat/brand")
public class WechatBrandController {

    @Autowired
    private WechatBrandFeign brandFeign;

    /**
     * 品牌闪购1
     * @return
     */
    @ApiOperation("品牌闪购")
    @PostMapping({"/ajaxbrandlist"})
    public String ajaxBrandList() {
        return brandFeign.ajaxHotActivity();
    }
    @RequestMapping("/ajaxbrandlistforindex")
    public String ajaxbrandlistforindex(){
        return brandFeign.ajaxbrandlistforindex();
    }
    @RequestMapping("/ajaxgetbrandlist")
    public String ajaxGetbrandList(String custId){
       return brandFeign.ajaxGetbrandList(custId);
    }
    @PostMapping("/addbrand")
    public String addBrand(BrandVo brandvo, BindingResult result) {
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(brandvo);
        return brandFeign.addBrand(jsonObject,result);
    }

    @RequestMapping({"/getbrandlist"})
    public String getBrandList() {
        return brandFeign.getBrandList();
    }
    @GetMapping("/modifybrandwrite")
    public String modifyBrandWrite(Long tradeId) {
        return brandFeign.modifyBrandWrite(tradeId);
    }
    @PostMapping("/modifybrand")
    public String modifyBrand( BrandVo brandvo, BindingResult result) {
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(brandvo);
        return brandFeign.modifyBrand(jsonObject,result);
    }
    @PostMapping("/ajaxdeletebrand")
    public String ajaxDeleteBrand( BrandVo brandVo) {
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(brandVo);
        return brandFeign.ajaxDeleteBrand(jsonObject);
    }
}
